package ventanas;
import java.rmi.RemoteException;

import interfaces.AdministracionCentralInterface;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import beans.Proveedor;
import cliente.ClienteAdminCentral;
import controladores.ControladorGenerarOrdenCompra;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaGenerarOC extends javax.swing.JFrame {

	private static final long serialVersionUID = -922437579314231683L;

	private JTextField txtFecha;
	
	private JLabel lblProveedor;

	private JButton btnCancelar;
	
	private JButton btnCrearOC;
	
	private JComboBox cmbProveedor;

	private JButton btnAgregarProducto;

	private JLabel lblFecha;

	private ControladorGenerarOrdenCompra controlador;
	
	public JTextField getTxtFecha() {
		return txtFecha;
	}

	public void setTxtFecha(JTextField txtFecha) {
		this.txtFecha = txtFecha;
	}



	public void setTxtCuit(JTextField txtCuit) {
	}


	public void setTxtProveedor(JTextField txtProveedor) {
	}


	public void setTxtCantidad(JTextField txtCantidad) {
	}


	public void setTxtNombreProd(JTextField txtNombreProd) {
	}

	public VentanaGenerarOC() {
		super();
		initGUI();
		setVisible(true);
		controlador = new ControladorGenerarOrdenCompra(this);
		btnCrearOC.addActionListener(controlador);
		btnAgregarProducto.addActionListener(controlador);
		btnCancelar.addActionListener(controlador);
	}
	
	public JButton getBtnCancelar() {
		return btnCancelar;
	}

	public void setBtnCancelar(JButton btnCancelar) {
		this.btnCancelar = btnCancelar;
	}

	public JButton getBtnCrearOC() {
		return btnCrearOC;
	}

	public void setBtnCrearOC(JButton btnCrearOC) {
		this.btnCrearOC = btnCrearOC;
	}

	public JButton getBtnAgregarProducto() {
		return btnAgregarProducto;
	}

	public void setBtnAgregarProducto(JButton btnAgregarProducto) {
		this.btnAgregarProducto = btnAgregarProducto;
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				lblFecha = new JLabel();
				getContentPane().add(lblFecha);
				lblFecha.setText("Fecha:");
				lblFecha.setBounds(78, 115, 47, 16);
			}
			{
				txtFecha = new JTextField();
				getContentPane().add(txtFecha);
				txtFecha.setBounds(137, 112, 182, 22);
			}
			{
				lblProveedor = new JLabel();
				getContentPane().add(lblProveedor);
				lblProveedor.setText("Proveedor:");
				lblProveedor.setBounds(54, 21, 71, 16);
			}
	
			{
				{
					btnAgregarProducto = new JButton();
					getContentPane().add(btnAgregarProducto);
					btnAgregarProducto.setText("Agregar Productos");
					btnAgregarProducto.setBounds(134, 64, 190, 25);
				}
				{
					btnCrearOC = new JButton();
					getContentPane().add(btnCrearOC);
					btnCrearOC.setText("Crear Orden Compra");
					btnCrearOC.setBounds(44, 212, 179, 32);
				}
				{
					btnCancelar = new JButton();
					getContentPane().add(btnCancelar);
					{
						cmbProveedor = new JComboBox();
						cargarComboProveedores( cmbProveedor );
						getContentPane().add(cmbProveedor);
						cmbProveedor.setBounds(134, 18, 190, 29);
					}
					btnCancelar.setText("Cancelar");
					btnCancelar.setBounds(253, 213, 149, 25);
				}
			}
			pack();
			this.setSize(488, 320);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public JComboBox getCmbProveedor() {
		return cmbProveedor;
	}

	public void setCmbProveedor(JComboBox cmbProveedor) {
		this.cmbProveedor = cmbProveedor;
	}
	
	public void cargarComboProveedores ( JComboBox cmbProve )
	{
		try {
			for (Proveedor prove : ClienteAdminCentral.obtenerSistema().obtenerProveedores())
			{
				cmbProveedor.addItem(prove.getNombre());
			}
		} catch (RemoteException e)
		{
			e.printStackTrace();
		}
	}

}
